<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const obj = {
            name: 'laowang',
            age: 18


        }
        Object.defineProperty(obj, 'name', {
            value: "laowang",
            writable: false,
            enumerable: false,
            configurable: false,
        })
        obj.name = 'lily'

        Object.defineProperty(obj,'age',{
            get() {
                console.log("获取值了");
          return 18;
            },
            set(newValue){
                console.log("值更信息了");  
            }
        });
        obj.age++
    </script>
</body>

</html>